-
Couldn't load subscription status.
- Fork 3.8k
CASSANDRA-20982: Restrict BytesType value compatibility to scalar types, exclude collections and UDTs #4439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
BytesType.isValueCompatibleWith() previously accepted all types, including frozen collections and UDTs. This was incorrect because converting collections or UDTs to raw bytes is nonsensical - it allows reading raw serialized bytes which have no meaningful interpretation. This patch restricts BytesType to only accept simple scalar types by checking !isCollection() && !isUDT() in isValueCompatibleWithInternal(). patch by Dekrate for CASSANDRA-20982
test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
Outdated
Show resolved
Hide resolved
Replace isCollection() && isUDT() checks with isMultiCell() for cleaner code. Update error message in AlterTableStatement to more clearly indicate that we're adding a column of incompatible type with a previously dropped column, rather than suggesting the dropped column had the new type. Update tests to match the new error message format. patch by Dekrate for CASSANDRA-20982
|
@smiklosovic, done |
| return true; | ||
| // BytesType should only be compatible with simple scalar types, not with collections or UDTs | ||
| // because converting a collection or UDT to raw bytes is nonsensical | ||
| return !otherType.isMultiCell(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this here will break cql CAST operations, which I think we still might want to allow since they are explicit, and different from finding a column you re-added contains junk bytes.
Also, isMultiCell will return false for frozen collections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driftx, should I revert to the first version?
return !otherType.isCollection() && !otherType.isUDT();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and we shouldn't do this in isValueCompatibleWithInternal since it will prevent CASTing to bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driftx, thanks! Could you please suggest any particular place to put it in?
To sum up:
isValueCompatibleWithInternalreturns true backreturn !otherType.isCollection() && !otherType.isUDT();will be in the other place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this isSerializationCompatibleWith?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isSerializationCompatibleWith will prevent the schema change but still allow the cast.
Restrict BytesType compatibility to scalar types only
BytesType.isValueCompatibleWith() previously accepted all types,
including frozen collections and UDTs. This was incorrect because
converting collections or UDTs to raw bytes is nonsensical - it
allows reading raw serialized bytes which have no meaningful
interpretation.
This patch restricts BytesType to only accept simple scalar types
by checking !isCollection() && !isUDT() in isValueCompatibleWithInternal().
@driftx <- it was your task, I was happy to help!